<!DOCTYPE hrml>

<html>

<head>

    <title>商品审核</title>

    <include file='public/head'>

    <style>

        .layui-legend-size{font-size:14px !important;}

        .layui-nopadding{padding:0 !important;}

        .layui-overflow{overflow:auto;}

        .layui-nomargin{margin: 0 !important;}

        .layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}

        .layui-input{height:30px !important; }

        .layui-form-search-item .layui-inline{margin-bottom: 5px;} 

        .layui-form-search-item label{margin-left: 15px;}

        .layui-table-page {padding: 7px 0px 0px;}

        .layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}

    </style>

</head>

<body>

    <!-- layui-tab开始 -->

    <div class="layui-tab" lay-fliter="demo-tab">

        <!-- 顶部导航菜单开始 -->

        <div class="layui-tab-nav">

            <ul class="layui-tab-title">

                {:getNav('goods','goods_audit/index')};

            </ul>

        </div>



        <php>

            $is_admin = \plugins\store\Common::getAllowAccess();

        </php>



        <div class="layui-card">

            <!-- 搜索栏开始 -->

            <fieldset class="layui-elem-field layui-field-title layui-field-padding">

                <legend class="layui-legend-size">搜索</legend>

                <form class="layui-form table-bar" action="{:cmf_plugin_url('Goods://goods_audit/index')}" lay-filter="form-bar" method="post">

                    <div class="layui-form-search-item">

                        <label>关键字搜索:</label>

                        <div class="layui-inline" >

                            <div class="layui-input-inline" style="width: 100px;">

                                <select name="type" lay-verify="" class="layui-input">

                                    <option value="1" <?php if(empty($param['type']) || ($param['type']==1)) {echo 'selected';}?> >商品名称</option>

                                    <option value="2" <?php if(!empty($param['type']) && ($param['type']==2)) {echo 'selected';}?> >商品ID</option>

                                </select>

                            </div>

                            <div class="layui-input-inline" style="width: 100px;">

                                <input type="text" name="title" autocomplete="off" placeholder="请输入内容" class="layui-input" value="{$param.title|default=''}" style="width: 100px;">

                            </div>

                        </div>

                        <label>审核状态:</label>

                        <div class="layui-inline" >

                            <div class="layui-input-inline" style="width: 100px;">

                                <select name="status" lay-verify="" class="layui-input">

                                    <option value="-1" <?php if(empty($param['status'])) {echo 'selected';}?>>全部</option>

                                    <option value="1" <?php if(!empty($param['status'])&&($param['status']==1)) {echo 'selected';}?>>审核中</option>

                                    <option value="2" <?php if(!empty($param['status'])&&($param['status']==2)) {echo 'selected';}?>>审核通过</option>

                                    <option value="3" <?php if(!empty($param['status'])&&($param['status']==3)) {echo 'selected';}?>>审核驳回</option>

                                </select>

                            </div>

                        </div>

                        <label>时间:</label>

                        <div class="layui-inline">

                            <div class="layui-input-inline" style="width:100px;">
                            <input type="text" class="layui-input" id="test2" name="start_time" autocomplete="off" value="{$param.start_time|default=''}">

                            </div>

                        </div>—

                        <div class="layui-inline">

                            <div class="layui-input-inline" style="width:100px;">
                            <input type="text" class="layui-input" id="test3" name="end_time" autocomplete="off" value="{$param.end_time|default=''}">

                            </div>

                        </div>

                        <div class="layui-inline">

                        <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary " style="font-weight:800;" lay-submit="" lay-filter="demo2"><i class="layui-icon ">&#xe615;</i>搜索</button>

                        </div>

                    </div>

                </form>

            </fieldset>

            <!-- 搜索栏结束 -->

            <!-- 表头按钮开始 -->

            <div class="layui-card-header layui-bg-gray layui-bottom">



                <if condition="$is_admin === true ">

                    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger batchReject-btn" >批量驳回</a>

                    <a href="javascript:;" class="layui-btn layui-btn-xs batchAudit-btn" >批量通过</a>

                    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-warm set-btn"><i class="layui-icon ">&#xe614;</i>设置</a>

                    <else />

                    数据列表

                </if>

            </div>

            <!-- 表头按钮结束 -->

            <!-- 数据表格开始 -->

            <form method="post" id="f">

            <table class="layui-table layui-nomargin">

                <thead>

                    <tr>

                        <th rowspan="2" style="text-align:center;">

                            <input type="checkbox"  id="check-box-all" >

                        </th>

                        <th>商品ID</th>

                        <th>商品名称</th>

                        <th>审核状态</th>

                        <th>操作时间</th>

                        <th>驳回原因</th>

                        <th>操作</th>

                    </tr>

                </thead>

                <tbody>

                    <volist  name="data" id="vo">

                        <tr lay-fliter="test3">

                            <th style="text-align:center;">

                                <input type="checkbox" class="check-box " name="id[]" value="{$vo['id']}">

                             </th>

                            <td>{$vo.id}</td>

                            <td>{$vo.goods_name}</td>

                            <td><switch name="vo.audit_status">

                                <case value="1">审核中</case>

                                <case value="2">审核通过</case>

                                <case value="3">驳回</case>

                                <default/>???

                                </switch>

                            </td>

                            <td><empty name="vo.time">--<else/>{:date('Y-m-d H:i:s',$vo.time)}</empty></td>

                            <td>{$vo.reason|default=''}</td>

                            <td>

                                <div class="layui-btn-group">

                                <if condition="$is_admin === true ">

                                <eq name="vo.audit_status" value="1">

                                    <button type="button" data-goodsid="{$vo.id}" class="layui-btn layui-btn-primary layui-btn-xs adopt-btn" title="通过"><i class="layui-icon">&#xe605;</i></button>

                                    <button type="button" data-goodsid="{$vo.id}" class="layui-btn layui-btn-primary layui-btn-xs reject-btn" title="驳回"><i class="layui-icon">&#x1006;</i></button>

                                </eq>

                                </if>

                                <button type="button" data-goodsid="{$vo.id}" class="layui-btn layui-btn-primary layui-btn-xs log-btn" title="日志"><i class="layui-icon">&#xe642;</i></button>

                                <button type="button" data-goodsid="{$vo.id}" class="layui-btn layui-btn-primary layui-btn-xs details-btn" title="查看详情"><i class="layui-icon">&#xe602;</i></button>

                                </div>

                            </td>

                        </tr>

                    </volist>

                </tbody>

            </table>

            <!--分页-->

            <div class="layui-table-page">

                <div id="layui-table-page1">

                    <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">

                        {$page|default=''}

                    </div>

                </div>

            </div>

            </form>

            <!-- 数据表格结束 -->

        </div>

        <!-- 内容结束 -->

    </div>

    <!-- layui-tab结束 -->

    <include file='public/scripts'>

    <script>

    //全选/取消

    $('#check-box-all').on('click',function(){  

        $('.check-box').prop('checked',$('#check-box-all').prop('checked'));

        // console.log($('#check-box-all').prop('checked'));

    }); 

    layui.use('laydate', function(){

          var laydate = layui.laydate;

          //执行一个laydate实例
          laydate.render({

            elem: '#test2' //指定元素

          });
        //年月选择器

          laydate.render({

            elem: '#test3'

          });

        });



//设置

$('.set-btn').on('click',function(){

    let url = "{:cmf_plugin_url('Goods://goods_audit/auditSet')}";

    layer.open({

        type: 2

        ,title: '设置'

        ,shadeClose: true

        ,shade: 0.8

        ,area: ['700px', '500px']

        ,btn:['保存']

        ,fixed:false

        ,content: url //iframe的url

        ,yes:function(index, layero){

            //调用子页面方法

            // parentInfo = window["layui-layer-iframe" + index].callbackdata(index);

            var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：

            iframeWin.tijiao();

        }

    });

})



    //审核通过

    $('.adopt-btn').on('click',function(){

        let id = $(this).data('goodsid');

        //询问

        layer.confirm('确定审核通过吗？',{icon:3,title:'提示',btn:['通过','取消']}

        ,function(index,layero){

            console.log(111);

            $.ajax({

                url:"{:cmf_plugin_url('Goods://goods_audit/audit')}",

                type:'post',

                data:{goodsid:id},

                success:function(data){

                    if (data.code == 1) {

                        layer.msg(data.msg,{icon:1,time:1500},function(){

                            window.location.reload();

                        });

                    } else {

                        layer.msg(data.msg,{icon:2,time:1500});

                    }

                },

                error:function(data){

                    layer.msg('系统错误',{time:1200,icon:5});

                }

            })   

        },function(index){});

    })

    //审核驳回

    $('.reject-btn').on('click',function(){

        let id = $(this).data('goodsid');

        layer.prompt({

            formType: 2,

            value: '',

            title: '驳回原因',

            area: ['500px', '400px'] //自定义文本域宽高

            }, function(value, index, elem){

                $.ajax({

                    url:"{:cmf_plugin_url('Goods://goods_audit/reject')}",

                    type:'post',

                    data:{goodsid:id,reason:value},

                    success:function(data){

                        if (data.code == 1) {

                            layer.msg(data.msg,{icon:1,time:1500},function(){

                                window.location.reload();

                            });

                        } else {

                            layer.msg(data.msg,{icon:2,time:1500});

                        }

                    },

                    error:function(data){

                        console.log(data);

                        layer.msg('系统错误',{time:1200,icon:5});

                    }

                }) 

            layer.close(index);

            });

    });

    //批量通过

    $('.batchAudit-btn').on('click',function(){

        var id = $('#f').serialize();

        //询问

        layer.confirm('确定审核通过吗？',{icon:3,title:'提示',btn:['通过','取消']}

        ,function(index,layero){

            console.log(111);

            $.ajax({

                url:"{:cmf_plugin_url('Goods://goods_audit/batchAudit')}",

                type:'post',

                data:id,

                success:function(data){

                    if (data.code == 1) {

                        layer.msg(data.msg,{icon:1,time:1500},function(){

                            window.location.reload();

                        });

                    } else {

                        layer.msg(data.msg,{icon:2,time:1500});

                    }

                },

                error:function(data){

                    console.log(data);

                    layer.msg('系统错误',{time:1200,icon:5});

                }

            })   

        },function(index){});

    })

        //批量驳回

    $('.batchReject-btn').on('click',function(){

        var id = $('#f').serialize();

        layer.prompt({

            formType: 2,

            value: '',

            title: '驳回原因',

            area: ['500px', '400px'] //自定义文本域宽高

            }, function(value, index, elem){

                $.ajax({

                    url:"{:cmf_plugin_url('Goods://goods_audit/batchReject')}?reason="+value,

                    type:'post',

                    data:id,

                    success:function(data){

                        if (data.code == 1) {

                            layer.msg(data.msg,{icon:1,time:1500},function(){

                                window.location.reload();

                            });

                        } else {

                            layer.msg(data.msg,{icon:2,time:1500});

                        }

                    },

                    error:function(data){

                        console.log(data);

                        layer.msg('系统错误',{time:1200,icon:5});

                    }

                }) 

            layer.close(index);

            });

    });

    //查看详情

    $('.details-btn').on('click', function(){

        let id = $(this).data('goodsid');

        // let url = "{:cmf_plugin_url('Goods://goods_audit/detailsPag')}?gid="+id;

        let url = "{:cmf_plugin_url('Goods://admin_index/goodsDetail')}?id="+id;

        layer.open({

        type: 2

        ,title: '查看'

        ,shadeClose: true

        ,shade: 0.8

        ,area: ['800px', '800px']

        ,btn:['关闭']

        ,fixed:false

        ,content: url //iframe的url

        ,btn2:function(index, layero){}

        });

    });

    //审核日志

    $('.log-btn').on('click',function(){

        let id = $(this).data('goodsid');

        let url = "{:cmf_plugin_url('Goods://goods_audit/logPage')}?gid="+id;

        layer.open({

            type: 2//基本层类型  0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）

            ,title: '日志'//层的标题

            ,shadeClose: true//是否点击遮罩关闭

            ,shade: 0.8//遮罩

            ,area: ['800px', '700px']//宽高

            ,btn:['关闭']//弹框按钮

            ,fixed:false//固定

            ,content: url //iframe的url

            ,btn2:function(index, layero){

            }

        });

    });

    </script>

</body>

</html>